---
layout: "default"
title: "Operator: &-"
description: "Swift documentation for the '&-' operator."
root: "/v4.2"
---

<code class="language-swift"> operator &amp;- {
    associativity left
    precedence 
}</code>

<h3>Declarations</h3>

<div class="declaration inherited" id="func-ampmns_-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmns_-self-rhs_-self">func &amp;-(<wbr>_:<wbr> Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmns_-self-rhs_-self"><div class="p">
    <p>Returns the difference of the two given values, discarding any overflow.</p>

<p>The masking subtraction operator (<code>&amp;-</code>) silently discards any overflow
that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">let x: UInt8 = 21 &amp;- 10
// x == 11
let y: UInt8 = 10 &amp;- 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-(lhs: Self, rhs: Self) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>,    <a href="../../protocol/SignedInteger/"><code>SignedInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmns_-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmns_-self-rhs_-self">func &amp;-(<wbr>_:<wbr> Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmns_-self-rhs_-self"><div class="p">
    <p>Returns the difference of the two given values, discarding any overflow.</p>

<p>The masking subtraction operator (<code>&amp;-</code>) silently discards any overflow
that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">let x: UInt8 = 21 &amp;- 10
// x == 11
let y: UInt8 = 10 &amp;- 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-(lhs: Self, rhs: Self) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>,    <a href="../../protocol/SignedInteger/"><code>SignedInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmns_-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmns_-self-rhs_-self">func &amp;-(<wbr>_:<wbr> Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmns_-self-rhs_-self"><div class="p">
    <p>Returns the difference of the two given values, discarding any overflow.</p>

<p>The masking subtraction operator (<code>&amp;-</code>) silently discards any overflow
that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">let x: UInt8 = 21 &amp;- 10
// x == 11
let y: UInt8 = 10 &amp;- 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-(lhs: Self, rhs: Self) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>,    <a href="../../protocol/SignedInteger/"><code>SignedInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmns_-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmns_-self-rhs_-self">func &amp;-(<wbr>_:<wbr> Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmns_-self-rhs_-self"><div class="p">
    <p>Returns the difference of the two given values, discarding any overflow.</p>

<p>The masking subtraction operator (<code>&amp;-</code>) silently discards any overflow
that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">let x: UInt8 = 21 &amp;- 10
// x == 11
let y: UInt8 = 10 &amp;- 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-(lhs: Self, rhs: Self) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>,    <a href="../../protocol/SignedInteger/"><code>SignedInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmns_-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmns_-self-rhs_-self">func &amp;-(<wbr>_:<wbr> Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmns_-self-rhs_-self"><div class="p">
    <p>Returns the difference of the two given values, discarding any overflow.</p>

<p>The masking subtraction operator (<code>&amp;-</code>) silently discards any overflow
that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">let x: UInt8 = 21 &amp;- 10
// x == 11
let y: UInt8 = 10 &amp;- 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-(lhs: Self, rhs: Self) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>,    <a href="../../protocol/SignedInteger/"><code>SignedInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmns_-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmns_-self-rhs_-self">func &amp;-(<wbr>_:<wbr> Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmns_-self-rhs_-self"><div class="p">
    <p>Returns the difference of the two given values, discarding any overflow.</p>

<p>The masking subtraction operator (<code>&amp;-</code>) silently discards any overflow
that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">let x: UInt8 = 21 &amp;- 10
// x == 11
let y: UInt8 = 10 &amp;- 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-(lhs: Self, rhs: Self) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmns_-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmns_-self-rhs_-self">func &amp;-(<wbr>_:<wbr> Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmns_-self-rhs_-self"><div class="p">
    <p>Returns the difference of the two given values, discarding any overflow.</p>

<p>The masking subtraction operator (<code>&amp;-</code>) silently discards any overflow
that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">let x: UInt8 = 21 &amp;- 10
// x == 11
let y: UInt8 = 10 &amp;- 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-(lhs: Self, rhs: Self) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmns_-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmns_-self-rhs_-self">func &amp;-(<wbr>_:<wbr> Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmns_-self-rhs_-self"><div class="p">
    <p>Returns the difference of the two given values, discarding any overflow.</p>

<p>The masking subtraction operator (<code>&amp;-</code>) silently discards any overflow
that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">let x: UInt8 = 21 &amp;- 10
// x == 11
let y: UInt8 = 10 &amp;- 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-(lhs: Self, rhs: Self) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmns_-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmns_-self-rhs_-self">func &amp;-(<wbr>_:<wbr> Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmns_-self-rhs_-self"><div class="p">
    <p>Returns the difference of the two given values, discarding any overflow.</p>

<p>The masking subtraction operator (<code>&amp;-</code>) silently discards any overflow
that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">let x: UInt8 = 21 &amp;- 10
// x == 11
let y: UInt8 = 10 &amp;- 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-(lhs: Self, rhs: Self) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmns_-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmns_-self-rhs_-self">func &amp;-(<wbr>_:<wbr> Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmns_-self-rhs_-self"><div class="p">
    <p>Returns the difference of the two given values, discarding any overflow.</p>

<p>The masking subtraction operator (<code>&amp;-</code>) silently discards any overflow
that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">let x: UInt8 = 21 &amp;- 10
// x == 11
let y: UInt8 = 10 &amp;- 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-(lhs: Self, rhs: Self) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
